/**
 * User: alesj
 * Date: 11.1.2006
 * Time: 12:26:20
 * 
 * (C) Genera Lynx d.o.o.
 */

package com.alesj.blueberry.par.basic;

import javax.persistence.*;
import java.util.Date;
import java.io.Serializable;

/**
 * Error log.
 * Unexpected exceptions.
 * Unrecoverable.
 * ...
 *
 * @author <a href="mailto:ales.justin@genera-lynx.com">Ales Justin</a>
 */
@Entity
@Table(name = "error_log")
public class ErrorLog implements Serializable {

    private Integer id;
    private RequestEntry requestEntry;
    private String exceptionMessage;
    private Date serverDate;
    private int commiterIndex;

    public ErrorLog() {
    }

    public ErrorLog(RequestEntry requestEntry, String exceptionMessage, Date serverDate, int commiterIndex) {
        this.requestEntry = requestEntry;
        requestEntry.addErrorLog(this);
        this.exceptionMessage = exceptionMessage;
        this.serverDate = serverDate;
        this.commiterIndex = commiterIndex;
    }

    @Id
    @GeneratedValue
    @Column(name = "error_log_id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne
    @JoinColumn(name = "request_entry_id", unique = false, nullable = false, insertable = true, updatable = true)
    public RequestEntry getRequestEntry() {
        return requestEntry;
    }

    public void setRequestEntry(RequestEntry requestEntry) {
        this.requestEntry = requestEntry;
    }

    @Column(name = "server_date")
    public Date getServerDate() {
        return serverDate;
    }

    public void setServerDate(Date serverDate) {
        this.serverDate = serverDate;
    }

    @Column(name = "exc_msg")
    public String getExceptionMessage() {
        return exceptionMessage;
    }

    public void setExceptionMessage(String exceptionMessage) {
        this.exceptionMessage = exceptionMessage;
    }

    @Column(name = "commiter_index")
    public int getCommiterIndex() {
        return commiterIndex;
    }

    public void setCommiterIndex(int commiterIndex) {
        this.commiterIndex = commiterIndex;
    }

}
